package com.bdqn.gulimall.order.interceptor;

import com.bdqn.gulimall.order.service.OrderService;
import com.bdqn.gulimall.order.vo.PayAsyncVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * OrderPayedListener
 *
 * @author f
 * @since 2022/3/10
 */
@RestController
public class OrderPayedListener {

    @Resource
    OrderService orderService;

    @PostMapping("/payed/notify")
    public String handleAlipayed(PayAsyncVo vo, HttpServletRequest request){
        // 收到支付宝给的异步通知后（告知订单支付成功），返回success，支付宝就不再通知
        // Map<String, String[]> map = request.getParameterMap();
        // for (String key : map.keySet()) {
        //     String value = request.getParameter(key);
        //     System.out.println("参数名" + key + "  参数值" + value);
        // }

        //处理支付结果
        String result = orderService.handlePayResult(vo);


        return result;
    }
}
